Skip to content

Conversation

@arnaugiralt
Copy link
Member

@arnaugiralt arnaugiralt commented Feb 22, 2024

Several things are sub-par in the current implementation:

  • The $size event is triggered using an interval
  • Size is based on the document element

This PR refactors the way we trigger the $size event and how we calculate the size itself:

  • Replaces interval-based size update with a ResizeObserver instance.
  • Uses the body element to measure size, to avoid issues that come with using the document element

Also added "overflow:scroll" to the View widget's content holder element, so we have a behaviour more in line with the Connect SPA.

These changes are backwards compatible, since there is no external API to mess with the $size event, so no need to update the major version after this is merged.

- Replace interval-based size update with a ResizeObserver instance
- Use the body element to measure size, to avoid issues that come with using the document element
- Add "overflow:scroll" to the View widget content holder element
@sonarqubecloud
Copy link

if (type === '$size') {
const { height, width } = document.body.getBoundingClientRect();
data = { height, width };
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's nice!!!

@arnaugiralt arnaugiralt merged commit bc6ce16 into master Feb 23, 2024
@arnaugiralt arnaugiralt deleted the feat/refactor-size-event-behavior branch February 23, 2024 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants